#pragma once
#include <cstddef>   
#include <iosfwd>
namespace yiwei {
	class string {
	public:
		string(const char* str = "");
		string(const string& s);
		~string();


		string& operator=(string s);

		void Swap(string& s);
		
		typedef char* iterator;
		iterator begin() const;
		iterator end() const;


		char& operator[](size_t i);
		const char& operator[](size_t i) const;


		size_t size() const;
		size_t capacity() const;
		void reserve(size_t n);
		void resize(size_t n, char ch = '\0');


		void push_back(char ch);
		void append(const char* str);
		string& operator+=(char ch);
		string& operator+=(const char* str);
		string& insert(size_t pos, char ch);
		string& insert(size_t pos, const char* str);
		string& erase(size_t pos, size_t len = npos);


		size_t find(char ch, size_t pos = 0) const;
		size_t find(const char* str, size_t pos = 0) const;


		bool operator<(const string& s) const;
		bool operator==(const string& s) const;
		bool operator<=(const string& s) const;
		bool operator>(const string& s) const;
		bool operator>=(const string& s) const;
		bool operator!=(const string& s) const;

		const char* c_str();

	private:

		char* _str;
		size_t _size;
		size_t _capacity;

		static size_t npos;
	};

	std::istream& operator>>(std::istream& in, string& s);
	std::ostream& operator<<(std::ostream& out, const string& s);

}